package com.razor.data;

import com.alibaba.fastjson.JSONObject;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.util.HashMap;

/**
 * 类描述
 *
 * @author razor.liu
 * @version 1.0
 * @date 2021/8/13 10:20 上午
 */
public class XlStatusDataFix {

    static HashMap<Integer,OrderStatus> map = new HashMap<>();

    static XSSFSheet sheet;

    public XlStatusDataFix() {
        map.put(OrderStatus.Create.getStatus(), OrderStatus.Create);
        map.put(OrderStatus.Matching.getStatus(), OrderStatus.Matching);
        map.put(OrderStatus.Pickup.getStatus(), OrderStatus.Pickup);
        map.put(OrderStatus.Waiting.getStatus(), OrderStatus.Waiting);
        map.put(OrderStatus.Going.getStatus(), OrderStatus.Going);
        map.put(OrderStatus.Complete.getStatus(), OrderStatus.Complete);
        map.put(OrderStatus.SendBill.getStatus(), OrderStatus.SendBill);
        map.put(OrderStatus.Over.getStatus(), OrderStatus.Over);
        map.put(OrderStatus.Cancel.getStatus(), OrderStatus.Cancel);
    }


    public static void main(String[] args) {
        FileInputStream fileInputStream = null;
        String filePath = "/Users/razor/Downloads/订单数据不一致.xlsx";
        String sheetName = "sheet1";
        try {
            fileInputStream = new FileInputStream(filePath);
            XSSFWorkbook sheets = new XSSFWorkbook(fileInputStream);
            //获取sheet
            sheet = sheets.getSheet(sheetName);
        } catch (Exception e) {
            e.printStackTrace();
        }

        //获取行数
        int rows = sheet.getPhysicalNumberOfRows();
        for(int i=0;i<rows;i++){
            //获取列数
            XSSFRow row = sheet.getRow(i);
            int columns = row.getPhysicalNumberOfCells();
            //获取内容并且打印
            for(int j=0;j<columns;j++){
                String cell = row.getCell(j).toString();
                System.out.print(cell+"  ");
            }
            System.out.println("");
        }
    }
}
